package com.badibadi.mytools;

import java.util.List;

import com.badibadi.activity.MyFriendsResultActivity;
import com.badibadi.infos.MyFriendsModel;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;

public class FriendsTool {
	/**
	 * 筛选String中最后一个字符是否是@
	 * 
	 * @param content
	 *            content不能传入null或""
	 * @param context
	 *            上下文
	 * 
	 */
	public static void SearchFriends(String content, Context context) {
		if (content.substring(content.length() - 1, content.length()).equals(
				"@")) {
			Intent intent = new Intent(context, MyFriendsResultActivity.class);
			intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
			((Activity) context).startActivityForResult(intent, 3);
		}
	}

	/**
	 * 返回@好友全部的结果 pan(为空则返回的数据好友之间有空格，否则没有空格)
	 * 
	 * @return
	 */
	public static String BackAllResult(String pan, List<MyFriendsModel> listObj) {
		String d = "";
		if (listObj.size() > 0) {
			for (int i = 0; i < listObj.size(); i++) {
				if (listObj.get(i).isJudge()) {
					if (pan != null) {
						d = d + "@" + listObj.get(i).getNickName();
					} else {
						d = d + BackABC(listObj.get(i).getNickName());
					}
				}
			}
		}
		return d;
	}

	public static String BackABC(String d) {
		return "@" + d + " ";
	}
}
